<?php
class NewsController extends Controller{

    public function actionList() {
        $lang = $_GET['lang'];
        $page = isset($_GET['p']) ? $_GET['p'] : 1;
        $dataPerpage = 5;
        $newsList = News::getNewslist1($page, $dataPerpage, $lang, false);
        
        $this->render('newsList', array(
            "lang" => $lang,
            'data' => $newsList,
            'page' => $page,
            'dataPerpage' => $dataPerpage
        ));
    }

    public function actionDetail() {
        $lang = $_GET['lang'];
        if (isset($_GET['id'])) {
            $newsDetail = News::getNewsDetail($_GET['id'], $lang);
            $this->render('newsDetail', array(
                "lang" => $lang,
                'newsDetail' => $newsDetail
            ));
        } else {
            $this->redirect("index.php?lang={$lang}&r=News/List");
        }
    }
}

?>
